package com.yashi.springmvcjbpm.controller;

import java.io.UnsupportedEncodingException;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.yashi.springmvcjbpm.service.impl.JBPMServiceImpl;



@Controller
public class ExamController {
	JBPMServiceImpl jbpmServiceImpl = new JBPMServiceImpl();
	
	@RequestMapping(value="/examAction",method=RequestMethod.POST)
	public String execute(String taskId,String result) throws UnsupportedEncodingException{
		result= new String(result.getBytes("ISO-8859-1"),"UTF-8");//对乱码进行处理
		System.out.println("taskId="+taskId+",result="+result);
		Map leave=(Map) jbpmServiceImpl.getLeaveDetail(taskId).get(0);	//需要修改请假表中状态的数据，需要获得该记录
		if(result.equals("批准")){
			jbpmServiceImpl.updateLeave(leave, result);				//更新			
		}
		jbpmServiceImpl.completeTask(taskId, result);	//完成任务，进入下一个流程
		return "index";
	}
}
